import React, { FC } from 'react';
import { View, Text } from '@tarojs/components';
import { styled } from 'linaria/react';
import { useClassName } from '@/utils/index';
import { useLoadingOption } from './useLoadingOption';
import { LoadingContext, LoadingTypes } from '@/pages/MyCollection/LoadingComponent/LoadingContex';
type localCompProps = ICompProps & LoadingTypes;
export interface IProps extends localCompProps {}
LoadingComponent.defaultProps = {
    loadingText: '加载中...',
    completeText: '已加载全部内容',
    noDataText:'暂无数据'
} as Partial<IProps>;
function LoadingComponent(props: IProps) {
    const { className, style, ...other } = props;
    const localClassName = useClassName('LoadingComponent', className);
    const { CompOptions } = useLoadingOption(other.status);  
    return (
        <LoadingContext.Provider value={other}>
            <RootView className={localClassName} style={style}>
                {CompOptions}
            </RootView>
        </LoadingContext.Provider>
    );
}
export default React.memo(LoadingComponent as FC<IProps>);
const RootView = styled(View)`
    &.LoadingComponent {
      margin: 0 auto;
      font-size: 24px;
        font-weight: 400;
        color: #cbcdd6;
        text-align: center;
    }
`;
